package edu.pku.hawk.controller.util;

import java.io.Serializable;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;

public class MProducerQueue extends MQueue{

	private MessageProducer producer;

	public MProducerQueue(String queueName, Session session, MessageProducer producer) {
		super(queueName, session);
		this.producer = producer;
	}

	public void send(String str) throws JMSException {
		Message message = session.createTextMessage(str);
		producer.send(message);
	}
	
	public void send(Serializable object) throws JMSException {
		Message message = session.createObjectMessage(object);
		producer.send(message);
	}
	
	public void close() throws JMSException{
		if (this.producer != null)
			this.producer.close();
	}
}
